import { useSelectOptionsStore } from '@/store'
import { storeToRefs } from 'pinia'

// 解构store会使其失去响应式，需要使用storeToRefs使其保持响应式
export const useOptions = () => {
    const selectOptions = useSelectOptionsStore()
    const { allProjectOptions, allSiteOptions } = storeToRefs(selectOptions)
    const getProjects = (companyNo) => {
        return allProjectOptions.value.filter(item => item.companyNo === companyNo)
    }
    const getSite = (companyNo, projectNo) => {
        return allSiteOptions.value.filter(item => item.companyNo === companyNo && item.projectNo === projectNo)
    }
    return { getProjects, getSite }
}